<template>
  <div class="water-report">
    <div class="top-nav"></div>
    <div class="main-content">
      <div class="title-box">审计仪表盘</div>
      <div class="temperature-items">
        <div class="tp-item">
          <span class="item-title">站台平均温度：</span>
          <span class="item-value"
            >{{
              temperatureValueObj && temperatureValueObj.platformTemperature
            }}℃</span
          >
        </div>
        <div class="tp-item">
          <span class="item-title">站厅平均温度：</span>
          <span class="item-value"
            >{{
              temperatureValueObj && temperatureValueObj.stationHallTemperature
            }}℃</span
          >
        </div>
        <div class="tp-item">
          <span class="item-title">设备间平均温度：</span>
          <span class="item-value"
            >{{
              temperatureValueObj && temperatureValueObj.deviceTemperature
            }}℃</span
          >
        </div>
        <div class="tp-item">
          <span class="item-title">外气平均温度：</span>
          <span class="item-value"
            >{{
              temperatureValueObj && temperatureValueObj.externalQiTemperature
            }}℃</span
          >
        </div>
      </div>

      <section class="center-main">
        <div class="water-analysis panel1">
          <div class="inner1">
            <div class="energy-items">
              <div class="item-box">
                <div class="now-value">
                  <span>{{
                    StationLevelValueObj && StationLevelValueObj.floorageValue
                  }}</span>
                  <span>kWh</span>
                </div>
                <div class="base-value">
                  基准:{{
                    StationLevelValueObj &&
                    StationLevelValueObj.floorageBenchmark
                  }}kWh
                </div>
                <div class="item-desc">单位建筑面积能耗</div>
              </div>
              <div class="item-box">
                <div class="now-value">
                  <span>{{
                    StationLevelValueObj &&
                    StationLevelValueObj.airConditioningValue
                  }}</span>
                  <span>kWh</span>
                </div>
                <div class="base-value">
                  基准:{{
                    StationLevelValueObj &&
                    StationLevelValueObj.airConditioningBenchmark
                  }}kWh
                </div>
                <div class="item-desc">单位空调面积能耗</div>
              </div>
              <div class="item-box">
                <div class="now-value">
                  <span>{{
                    StationLevelValueObj && StationLevelValueObj.equivalentValue
                  }}</span>
                  <span>吨</span>
                </div>
                <div class="base-value">
                  基准:{{
                    StationLevelValueObj &&
                    StationLevelValueObj.equivalentBenchmark
                  }}吨
                </div>
                <div class="item-desc">碳排放当量</div>
              </div>
            </div>
            <div class="execute-budget">
              <div class="inner4">
                <div class="skill-tips">
                  <div class="tips-desc">预算执行情况</div>
                  <div class="actual">
                    <span class="actual-color"></span>
                    <span class="actual-text">实际用量</span>
                  </div>
                  <div class="budget">
                    <span class="budget-color"></span>
                    <span class="budget-text">预算用量</span>
                  </div>
                </div>
                <div class="skill-items">
                  <Skill :datas="dataList"></Skill>
                </div>
              </div>
            </div>
          </div>
        </div>

        <div class="report-table panel1">
          <div class="inner1">
            <div class="table-option">
              <div class="table-data-box">
                <Vechart
                  class="option"
                  v-if="slectTag === 'area'"
                  :options="hourOptionData1"
                ></Vechart>
                <Vechart
                  class="option"
                  v-if="slectTag === 'air'"
                  :options="hourOptionData2"
                ></Vechart>
                <Vechart
                  class="option"
                  v-if="slectTag === 'COP'"
                  :options="hourOptionData3"
                ></Vechart>
              </div>
              <div class="option-check">
                <div
                  class="unit"
                  @click="checkInfo('area')"
                  :class="{ 'check-effect': slectTag === 'area' }"
                >
                  用电量
                </div>
                <div
                  class="unit"
                  @click="checkInfo('air')"
                  :class="{ 'check-effect': slectTag === 'air' }"
                >
                  用水量
                </div>
                <div
                  class="unit"
                  @click="checkInfo('COP')"
                  :class="{ 'check-effect': slectTag === 'COP' }"
                >
                  风水系统COP
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <section class="bottom-main">
        <div class="time-line">
          <el-button
            v-for="(item, index) in yearList"
            :key="index"
            class="date-item"
            :class="{ 'current-time': year == item }"
            @click="yearQuery(item)"
          >
            {{ item }}年
          </el-button>
        </div>
      </section>
    </div>
  </div>
</template>
<script>
import Skill from "../../components/skill/Skill";
import Vechart from "../../components/charts/Vcharts";
import righthour from "./echartsjson/options1.json";
import { yearArray } from "../../utils/index.js";
export default {
  name: "Auditdashboard",
  props: [
    "dataList",
    "temperatureValue",
    "StationLevelValue",
    "chartData1",
    "chartData2",
    "chartData3",
    "chartType",
  ],
  components: {
    Vechart,
    Skill,
  },
  data() {
    return {
      righthour: righthour,
      yearList: yearArray(),
      year: new Date().getFullYear() + "",
      slectTag: "area",
    };
  },

  methods: {
    checkInfo(type) {
      this.slectTag = type;
    },
    yearQuery(year) {
      this.$emit("Checkyear", year);
      this.year = year;
    },
  },
  computed: {
    temperatureValueObj() {
      if (Object.keys(this.temperatureValue).length) {
        return this.temperatureValue;
      }
    },
    StationLevelValueObj() {
      if (Object.keys(this.StationLevelValue).length) {
        return this.StationLevelValue;
      }
    },
    hourOptionData1() {
      let datas = this.chartData1;
      if (Object.keys(datas).length > 0 && datas.savedTime.length > 0) {
        return {
          ...this.righthour,
          xAxis: {
            ...this.righthour.xAxis,
            axisLabel: {
              ...this.righthour.xAxis.axisLabel,
            },
            data: datas.savedTime,
          },
          yAxis: [
            {
              ...this.righthour.yAxis[0],
              name: "耗电量（kWh ）",
            },
          ],
          series: [
            {
              ...this.righthour.series[0],
              type: this.chartType,
              data: datas.value,
            },
          ],
        };
      } else {
        return this.righthour;
      }
    },
    hourOptionData2() {
      let datas = this.chartData2;
      if (Object.keys(datas).length > 0 && datas.savedTime.length > 0) {
        return {
          ...this.righthour,
          xAxis: {
            ...this.righthour.xAxis,
            axisLabel: {
              ...this.righthour.xAxis.axisLabel,
            },
            data: datas.savedTime,
          },
          yAxis: [
            {
              ...this.righthour.yAxis[0],
              name: "用水量（m³）",
            },
          ],
          series: [
            {
              ...this.righthour.series[0],
              type: this.chartType,
              data: datas.value,
            },
          ],
        };
      } else {
        return this.righthour;
      }
    },
    hourOptionData3() {
      let datas = this.chartData3;
      if (Object.keys(datas).length > 0 && datas.savedTime.length > 0) {
        return {
          ...this.righthour,
          xAxis: {
            ...this.righthour.xAxis,
            axisLabel: {
              ...this.righthour.xAxis.axisLabel,
            },
            data: datas.savedTime,
          },
          yAxis: [
            {
              ...this.righthour.yAxis[0],
              name: "COP",
            },
          ],
          series: [
            {
              ...this.righthour.series[0],
              type: this.chartType,
              data: datas.value,
            },
          ],
        };
      } else {
        return this.righthour;
      }
    },
  },
};
</script>
<style lang="less" scoped>
.water-report {
  width: 100%;
  height: 100%;
  .top-nav {
    width: 10rem;
    height: 0.41rem;
  }
  .main-content {
    width: 10rem;
    height: calc(100% - 0.5rem);
    position: relative;
    .title-box {
      position: absolute;
      font-weight: bold;
      top: 10px;
      left: 0;
      font-size: 22px;
      color: #ffffff;
      text-align: center;
      width: 220px;
      height: 44px;
      line-height: 44px;
      background: url("../../assets/img/ti.png") no-repeat center;
      background-size: cover;
    }
    .temperature-items {
      width: 100%;
      height: 10%;
      //   background-color: #fff;
      display: flex;
      justify-content: space-around;
      padding: 0 280px;
      .tp-item {
        width: 240px;
        height: 100%;
        display: flex;
        align-items: center;
        text-align: center;
        // background-color: #09bdd7;
        .item-title {
          width: 180px;
          color: #84bfdd;
          font-size: 22px;
        }
        .item-value {
          width: 60px;
          color: #ffffff;
          font-size: 22px;
        }
      }
    }
    .top-main {
      width: 100%;
      height: 10%;
      display: flex;
      .water-conservation {
        width: 50%;
        height: 100%;
      }
      .equipment-operation {
        width: 50%;
        height: 100%;
      }
    }
    .center-main {
      width: 100%;
      height: 80%;
      display: flex;
      justify-content: space-around;
      padding: 0 2% 0 3%;
      .water-analysis {
        width: 35%;
        height: 100%;
        // background-color: #84bfdd;
        font-size: 20px;
        color: #fff;
        display: flex;
        flex-direction: column;
        .energy-items {
          width: 100%;
          height: 288px;
          // background: chartreuse;
          display: flex;
          justify-content: space-around;
          align-items: center;
          .item-box {
            width: 184px;
            height: 272px;
            // background-color: aliceblue;
            background: url("../../assets/img/icon3455.png") no-repeat bottom
              center;
            background-size: 100% 100%;
            text-align: center;
            .now-value {
              width: 140px;
              height: 140px;
              margin: 24px auto;
              padding-top: 24px;
              // background-color: aqua;
              display: flex;
              justify-content: center;
              align-items: center;
              flex-direction: column;
              span {
                font-size: 18px;
                font-weight: bold;
                color: #ffffff;
              }
            }
            .base-value {
              width: 120px;
              height: 24px;
              margin: 8px auto;
              color: #1075ba;
              font-size: 16px;
              line-height: 24px;
            }
            .item-desc {
              width: 158px;
              height: 36px;
              margin: 0 auto;
              background: url("../../assets/img/icon333.png") no-repeat bottom
                center;
              background-size: 100% 100%;
              font-size: 16px;
              color: #ffffff;
              line-height: 36px;
            }
          }
        }
        .execute-budget {
          flex: 1;
          .inner4 {
            .skill-tips {
              display: flex;
              width: 100%;
              height: 10%;
              text-align: center;
              justify-content: space-between;
              .tips-desc {
                width: 144px;
                height: 24px;
                font-size: 24px;
                font-weight: bold;
                color: #97daf8;
              }
              .actual {
                width: 144px;
                padding-top: 1%;
                .actual-color {
                  display: inline-block;
                  width: 11px;
                  height: 11px;
                  background: #09bdd7;
                  margin: 0 10px;
                }
                .actual-text {
                  color: #09bdd7;
                  font-size: 14px;
                }
              }
              .budget {
                width: 144px;
                padding-top: 1%;
                .budget-color {
                  display: inline-block;
                  width: 11px;
                  height: 11px;
                  background: #116cb0;
                  margin: 0 10px;
                }
                .budget-text {
                  color: #116cb0;
                  font-size: 14px;
                }
              }
            }
            .skill-items {
              width: 100%;
              height: 90%;
            }
          }
        }
      }
      .report-table {
        width: 62%;
        height: 100%;
        color: #fff;
        font-size: 20px;
        .table-option {
          // background-color: #fff;
          width: 100%;
          height: 100%;
          display: flex;
          flex-direction: column;
          .table-data-box {
            width: 100%;
            height: 90%;
            .main2-table {
              background-color: #050f23 !important;
            }
            /deep/.el-table tr {
              background-color: #050f23 !important;
            }
            /deep/.el-table__row.statistics-warning-row {
              background: #071635 !important;
            }
            /deep/.el-table__row.normal-now {
              background: #050f23 !important;
            }
          }
          .option-check {
            width: 100%;
            height: 10%;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: #050f23;
            user-select: none;
            .unit {
              cursor: pointer;
              margin: 0 20px;
              width: 150px;
              height: 44px;
              line-height: 44px;
              text-align: center;
              font-size: 15px;
              color: #28c2ff;
              border-radius: 10px;
              background-color: #0a73b1;
            }
            .check-effect {
              font-weight: bold;
              color: #ccc;
              background-color: #2b70b2;
            }
          }
        }
      }
    }
    .bottom-main {
      width: 100%;
      height: 10%;
      position: relative;
      .time-line {
        width: 50%;
        margin: 0 auto;
        cursor: pointer;
        height: 100%;
        background: url("../../assets/img/timeline.png") no-repeat center center;
        background-size: contain;
        display: flex;
        justify-content: center;
        align-items: center;
        .date-item {
          // width: 1rem;
          height: 44px;
          margin: 0 20px;
          text-align: center;
          background: #091c37;
          border: 1px solid #0a73b1;
          font-size: 16px;
          color: #28c2ff;
          border-radius: 6px;
          // line-height: 44px;
        }
        .current-time {
          background: #2b70b2;
          color: #fff;
          border: 2px solid #2b70b2;
        }
      }
    }
    .title-little-box {
      width: 680px;
      font-size: 28px;
    }
  }
}
</style>
